update preproc 2

Documentation Version for Comments and Changes

You are invited to make any changes...add any comments.

Changes will `eventually` be merged into the offical documentation.

Leave any commnents here...

...

... back to index page OE documentation



non-zero, you exit with abort(1), for example. </eucode>

So, that is our pre-processor. Now, how do we make use of it? First let's create a simple test program that we can watch it work with. Name this file thedate.eui.

-- thedate.eui 
 
puts(1, "The date this was run is @DATE@\n") 

Rather simple, but it shows off the pre-processor we have created. Now, let's run it, but first without a pre-processor hook defined.

NOTE: Through this document I am going to assume that you are working in Windows. If not, you can make the appropriate changes to the shell type examples.

C:\MyProjects\datesub> eui thedate.eui 
The date this was run is @DATE@ 

Not very helpful? Ok, let's tell Euphoria how to use the pre-processor that we just created and then see what happens.

C:\MyProjects\datesub> eui -p eui:datesub.ex thedate.eui 
The date this was run is 2009-08-05 19:36:22 

If you got something similar to the above output, good job, it worked! If not, go back up and check your code for syntax errors or differences from the examples above.

What is this -p paramater? In short, -p tells eui or euc that there is a pre-processor. The definition of the pre-processor comes next and can be broken into 2 required sections and 1 optional section. Each section is divided by a colon (:).
For example, -p e,ex:datesub.ex

  1. e,ex tells Euphoria that when it comes across a file with the extension e or ex that it should run a pre-processor
  2. datesub.ex tells Euphoria which pre-processor should be run. This can be a .ex file or any other executable command.
  3. An optional section exists to pass options to the pre-processor but we will go into this later.

That's it for the quick introduction. I hope that the wheels are turning in your head already as to what can be accomplished with such a system. If you are interested, please continue reading and see where things will get very interesting!

Pre-process Details

Euphoria manages when the pre-processor should be called and with what arguments. The pre-processor does not need to concern itself as to if it should run, what filename it is reading or what filename it will be writing to. It should simply do as Euphoria tells it to do. This is because Euphoria monitors what the modification time is on the source file and what time the last pre-process call was made on the file. If nothing has changed in the source file then the pre-processor is not called again. Pre-processing does have a slight penalty in speed as the file is processed twice. For example, the datesub.ex pre-processor

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu